import { request } from 'umi';

/**
 * 获取当前服务商下的权限角色
 * @returns 
 */
export async function role_list(params: Role.QueryForm) {
  return request<RoleResponse.ResList>('/api/service/role/list', { method: "GET", params });
}

export async function create_role(data: Role.CreateRole) {
  return request<RoleResponse.Base>('/api/service/role/create', { method: "POST", data });
}

export async function update_role(data: Role.UpdateRole) {
  return request<RoleResponse.Base>('/api/service/role/update', { method: "POST", data });
}
export async function change_role_status(data: Role.ChangeRoleStatus) {
  return request<RoleResponse.Base>('/api/service/role/change', { method: "POST", data });
}
export async function set_role_scopes(data: {role_id: number, scopes: number[]}) {
  return request<RoleResponse.Base>('/api/service/set/scopes', { method: "POST", data });
}

export async function delete_role(params: Role.DeleteRole) {
  return request<RoleResponse.Base>('/api/service/role/delete', { method: "GET", params });
}
export async function get_role(params: {role_id: number}) {
  return request<RoleResponse.Base>('/api/service/get/role', { method: "GET", params });
}
export async function rule_list() {
  return request<RoleResponse.Base>('/api/service/rule/list', {});
}